package com.dmall.chapter03.section03;

/**
 * 暴力解法
 * 时间复杂度：O(n^2)
 * 空间复杂度：O(1)
 *
 * @author xiao1.wang
 * @date 2020-12-01 10:41:59
 */
public class Leetcode11V1 {
    public int maxArea(int[] height) {
        int maxArea = 0;
        for (int i = 0; i < height.length - 1; i++) {
            for (int j = i + 1; j < height.length; j++) {
                maxArea = Math.max((j - i) * Math.min(height[i], height[j]), maxArea);
            }
        }
        return maxArea;
    }

    public static void main(String[] args) {
        int[] height = {1, 8, 6, 2, 5, 4, 8, 3, 7};
        Leetcode11V1 leetcode11 = new Leetcode11V1();
        System.out.println(leetcode11.maxArea(height));
    }
}
